# -*- bazel -*-

load("@drake//tools/skylark:cc.bzl", "cc_library")

licenses(["notice"])  # BSD-3-Clause

config_setting(
    name = "linux",
    values = {"cpu": "k8"},
)

DEPRECATION = "WARNING: The @gtest module extension provided by Drake is deprecated and will be removed on or after 2026-01-01, including removal of the gtest_repository() function. Please switch to the Bazel Central Registry module bazel_dep(name = 'googletest') instead."  # noqa

cc_library(
    name = "without_main",
    testonly = 1,
    srcs = glob(
        [
            "googlemock/src/*.cc",
            "googletest/src/*.cc",
            "googletest/src/*.h",
        ],
        exclude = [
            "googlemock/src/gmock_main.cc",
            "googletest/src/gtest_main.cc",
            "googlemock/src/gmock-all.cc",
            "googletest/src/gtest-all.cc",
        ],
    ),
    hdrs = glob([
        "googlemock/include/**/*.h",
        "googletest/include/**/*.h",
    ]),
    copts = ["-Wno-unused-const-variable"],
    defines = [
        "GTEST_DONT_DEFINE_FAIL=1",
        "GTEST_DONT_DEFINE_SUCCEED=1",
        "GTEST_DONT_DEFINE_TEST=1",
    ],
    includes = [
        "googlemock",
        "googlemock/include",
        "googletest",
        "googletest/include",
    ],
    linkopts = select({
        ":linux": ["-pthread"],
        "//conditions:default": [],
    }),
    linkstatic = 1,
    deps = [
        "@drake//common/test_utilities:gtest_printers",
    ],
    visibility = ["//visibility:public"],
    deprecation = DEPRECATION,
)

cc_library(
    name = "main",
    testonly = 1,
    srcs = ["googlemock/src/gmock_main.cc"],
    linkstatic = 1,
    visibility = ["//visibility:public"],
    deps = [
        ":without_main",
    ],
    deprecation = DEPRECATION,
)
